#include "synch.h"

class BoundedBuffer2 {
   public:
     // create a bounded buffer with a limit of 'maxsize' bytes
     BoundedBuffer2(int maxsize);
     ~BoundedBuffer2();
	 
	 //Deposit only one-byte data on buffer
	 void Deposit(void *data);

	//Remove only one-byte data on buffer
	//Return its address
	void *Remove();

     // read 'size' bytes from the bounded buffer, storing into 'data'.
     // ('size' may be greater than 'maxsize')
     void Read(char *data, int size);
     
     // write 'size' bytes from 'data' into the bounded buffer.
     // ('size' may be greater than 'maxsize')
     void Write(char *data, int size);
	 
	 //To judge if the Buffer is full
	 bool isFull();
	 
	 //To judge if the Buffer is empty
	 bool isEmpty();
   private:
   int head;//Used buffer's head
   int tail;//Used buffer's tail
   char *buffer;//buffer
   int max;//buffer's maxsize
   int usage;//buffer's used size
   Semaphore *mutex;//protect buffer list from
					//editted by two or more threads
   Semaphore *fullbuffers;//sign on if buffer is full
   Semaphore *emptybuffers;//sign on if buffer is empty
     // ???
};

